package com.hwd.srb.core.enmu;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Arrays;

/**
 * @author 黄伟东/Victor
 * @date 2022/3/25 17:15
 * @Description 关系枚举类
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum RelationEnum {

    COUPLE(1, "夫妻"),
    BROTHER_AND_SISTER(2, "兄妹"),
    PARENT(3, "父母"),
    OTHER(4, "其他"),
    ;

    @EnumValue
    private Integer value;

    @JsonValue
    private String relation;

    @Override
    public String toString() {
        return this.relation;
    }

    public static String getRelationByValue(int value) {
        return Arrays.stream(RelationEnum.values())
                .filter(i -> i.getValue() == value)
                .map(RelationEnum::getRelation)
                .findFirst()
                .orElse("");
    }
}
